package com.szty.libarytest.webTest

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.LinearLayout
import com.just.agentweb.AgentWeb
import com.szty.libarytest.R
import kotlinx.android.synthetic.main.activity_web_test.*

class WebTestActivity : AppCompatActivity() {
    private val url = "https://ws.wsuyun.cn/train/index.php/user/Star/ln_sign"
    private var mAgentWeb:AgentWeb? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_web_test)
        btn_reload.setOnClickListener {
            mAgentWeb?.urlLoader?.reload()
        }
        initAgentWeb()
    }
    private fun initAgentWeb() {
         mAgentWeb = AgentWeb.with(this)
            .setAgentWebParent(wb_test, LinearLayout.LayoutParams(-1, -1))
            .useDefaultIndicator(Color.TRANSPARENT, 0)   //进度条，第一个参数是进度条的颜色，第二个参数是进度条的高度，这里需要隐藏进度条
            .createAgentWeb()
            .ready()
            .go(url)
        mAgentWeb?.jsInterfaceHolder?.addJavaObject(
            "android",
            AndroidInterface()
        )
    }

}